<?php

require_once('db/db.php');

$db=new DB;

function check($name){
	if(isset($_REQUEST[$name])){
		return $_REQUEST[$name];
	}
	else{
		die();
	}
}

$name=check('name');
$product_link=check('product_link');
$pic_link=check('pic_link');
$desc=check('desc');
$click_counts=check('click_counts');
$love_counts=check('love_counts');
$category=check('category');
$discount=check('discount');
$price=check('price');
$prime_price=check('prime_price');



$sql = "insert into `product` (`name`,`product_link`,`pic_link`,`desc`,`click_counts`,`love_counts`,`category`,`discount`,`price`,`prime_price`)
		values ('$name','$product_link','$pic_link','$desc','$click_counts','$love_counts','$category','$discount','$price','$prime_price')";

if(!$db->query($sql)){
	return false;
}

echo json_encode(array(
	'id' => mysql_insert_id(),
	'name' => $name,
	'product_link' => $product_link,
	'pic_link' => $pic_link,
	'desc' => $desc,
	'click_counts' => $click_counts,
	'love_counts' => $love_counts,
	'category' => $category,
	'discount' => $discount,
	'price' => $price,
	'prime_price' => $prime_price
));

?>
